#include "Meniu.h"

Meniu::Meniu(void)
{
};

void Meniu::AddButton(buton *But)
{
	this->butoane.push_back(But);
};

void Meniu::RemoveButton(char *label)
{
	vector<buton *>::iterator it;
	for ( it=this->butoane.begin() ; it < this->butoane.end(); it++ )
		if ( strcmp((*it)->label,label) == 0)
		{
			this->butoane.erase(it);
			break;
		}
};

bool Meniu::Menuclicked(GLdouble x ,GLdouble y) 
{
	vector<buton *>::iterator it;
	for ( it=this->butoane.begin() ; it < this->butoane.end(); it++ )
		(*it)->clicked(x,y);
	return true;
}
void Meniu::Menurelease(GLdouble xt,GLdouble yt, GLdouble mousex,GLdouble mousey)
{
	vector<buton *>::iterator it;
	for ( it=this->butoane.begin() ; it < this->butoane.end(); it++ )
		(*it)->release(xt,yt,mousex,mousey);
};

void Meniu::Menupress(GLdouble x ,GLdouble y) 
{
	vector<buton *>::iterator it;
	for ( it=this->butoane.begin() ; it < this->butoane.end(); it++ )
		(*it)->press(x,y);
};

void Meniu::Menupasiv(GLdouble x ,GLdouble y, GLdouble mousex,GLdouble mousey) 
{
	vector<buton *>::iterator it;

	for ( it=this->butoane.begin() ; it < this->butoane.end(); it++ )
	{
		if ((*it)->pasiv(x,y,mousex,mousey))
		{
			vector<buton *>::iterator it2;
			for ( it2=this->butoane.begin() ; it2 < this->butoane.end(); it2++ )
				if (it != it2)
					(*it2)->highlighted = 0;
		}
	}
};

void Meniu::Menudraw(void)
{
	vector<buton *>::iterator it;
	for ( it=this->butoane.begin() ; it < this->butoane.end(); it++ )
		(*it)->draw();
};

Meniu::~Meniu(void)
{
};
